#ifndef __GATEWAYSERVERSENDER_H__
#define __GATEWAYSERVERSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../NetMessage.h"
#include "gatewayserver.pb.h"

/**
*@file       GatewayServerSender.h
*@brief      send message GatewayServer
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/16
*/

///message wrapper
class msgGatewayServer
{
public:
    static const int MessageId = GatewayServer;
    //TODO
    pnSessionHandle   SessionId;
    GatewayServerMain MainMsg;
    ///@brief    constructor
    ///param[in] session_id   identifier of the session
    ///param[in] sub_id       sub message id
    ///param[in] buffer       message buffer
    msgGatewayServer(int session_id, int sub_id, const std::string& buffer):
    SessionId(session_id)
    {
        MainMsg.set_subid(sub_id);
        MainMsg.set_subbuffer(buffer);
    }
};

class HandleGatewayServer
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of GatewayServer
    ///retval     void
    static void HandleMessage(msgGatewayServer* msg)
    {
        //TODO
        ProtoNet<GatewayServerMain>::Send(msg->SessionId, msgGatewayServer::MessageId, msg->MainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgGatewayServer, HandleGatewayServer);

#endif
